package vtc;

import java.util.*;
import java.util.concurrent.*;
import java.io.*;

// Many input queues and one single output queue

abstract class SynchronizationUnit extends VtcUnit 
{
	
	protected Object [] eventsVector_;
	protected Date timeTag_;
	
	SynchronizationUnit(String id, VtcArrayBlockingQueue inQueues[], VtcArrayBlockingQueue outQueues[]) 
	{
		super(id, inQueues, outQueues);
		eventsVector_ = new Object[inQueues_.length];
	}
	
	//this method should define the vector of events and the common time tag
	abstract public void synchronizationProcess() throws InterruptedException;
	
	public void process() throws InterruptedException
	{
		synchronizationProcess();
		VtcTimeTaggedEvent event = new VtcTimeTaggedEvent(eventsVector_, timeTag_);
		outQueues_[0].forcePut(event);
	}
}